﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Roy.Site.Models;

namespace Roy.Site.Controllers
{
    public class JsonController : BaseController
    {
        /// <summary>
        /// 获取系统管理树的json
        /// </summary>
        /// <returns></returns>
        public JsonResult GetSystemManageTree()
        {
            List<TreeStore> nodes = new List<TreeStore>();

            TreeStore treeStoreRoot = new TreeStore 
            { 
                children= new List<TreeStore>()
                {
                    new TreeStore
                    {
                        id=101,
                        text="菜单管理",
                        qtitle= "Roy.view.system.menu.MenuManage",
                        leaf= true
                    },
                    new TreeStore
                    {
                        id=102,
                        text="机构管理",
                        qtitle= "Roy.view.system.OrgManage",
                        leaf= true
                    },
                    new TreeStore
                    {
                        id=103,
                        text="用户管理",
                        qtitle= "Roy.view.system.user.View",
                        leaf= true
                    },
                    new TreeStore
                    {
                        id=104,
                        text="角色管理",
                        qtitle= "Roy.view.system.RoleManage",
                        leaf= true
                    }
                },
                id= 100,
                text= "系统管理",
                cls= "folder",
                leaf= false,
                expanded= true
            };
            nodes.Add(treeStoreRoot);
            //return new JsonResult() { Data=nodes,JsonRequestBehavior= JsonRequestBehavior.AllowGet };
            return Json(nodes,JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 获取日志管理树json
        /// </summary>
        /// <returns></returns>
        public JsonResult GetLogManageTree()
        {
            List<TreeStore> nodes = new List<TreeStore>();

            TreeStore treeStoreRoot = new TreeStore
            {
                children = new List<TreeStore>()
                {
                    new TreeStore
                    {
                        id=201,
                        text="登录日志",
                        qtitle= "Roy.view.system.LoginLog",
                        leaf= true
                    },
                    new TreeStore
                    {
                        id=202,
                        text="操作日志",
                        qtitle= "Roy.view.system.OperationLog",
                        leaf= true
                    },
                    new TreeStore
                    {
                        id=203,
                        text="错误日志",
                        qtitle= "Roy.view.system.ErrorLog",
                        leaf= true
                    }
                },
                id = 200,
                text = "日志管理",
                cls = "folder",
                leaf = false,
                expanded = true
            };
            nodes.Add(treeStoreRoot);
            return new JsonResult() { Data = nodes, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }

    }
}
